<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>js模块化开发之闭包宽放大模式</title>
    <script>
        // 这段代码不能写在上面那段代码前面
        var moduleA = (function(mod){
            function showC(){
                alert("hello world");
            }

            mod.outC = showC;
            return mod;
        })(moduleA || {});

        var moduleA = (function(mod){
            var count = 10; //私有变量

            function showA(){ //私有函数
                count += 20;
                alert(count);
            }
            function showB(){
                count *= 10;
                alert(count);
            }

            mod.outA = showA;
            mod.outB = showB;
            //对外暴露
            return mod;
        })(moduleA || {});

        moduleA.outA();
        moduleA.outB();
        moduleA.outC();
    </script>
</head>
<body>
    
</body>
</html>